package v1

import (
	"authserver/global/response"
	"authserver/model"
	"authserver/service"
	"github.com/gin-gonic/gin"
)

// AddAudio
// @Summary 添加音频
// @Router /api2/addAudio [post]
func AddAudio(c *gin.Context) {

	var param model.BookAudio
	_ = c.ShouldBindJSON(&param)

	err := service.AddBookAudio(param)
	if err != nil {
		response.FailWithMessage("获取失败", c)
		return
	}
	response.OkWithMessage("", c)
	return
}

// GetAllAudioClass
// @Summary 年级列表
// @Router /api2/getAllClass [post]
func GetAllAudioClass(c *gin.Context) {

	var param model.BookAudio
	_ = c.ShouldBindJSON(&param)

	err, allClass := service.GetAllClass()
	if err != nil {
		response.FailWithMessage("获取失败", c)
		return
	}
	response.OkWithData(allClass, c)
	return
}

// GetAllClassGroup
// @Summary 获取所有书目
// @Router /api2/getAllClassGroup [post]
func GetAllClassGroup(c *gin.Context) {

	var param model.BookMenu
	_ = c.ShouldBindJSON(&param)

	err, allGroup := service.GetAllBooks(param)
	if err != nil {
		response.FailWithMessage("获取失败", c)
		return
	}
	response.OkWithData(allGroup, c)
	return
}

// GetAllClassGroupAudio
// @Summary 获取所有音频
// @Router /api2/getAllClassGroupAudio [post]
func GetAllClassGroupAudio(c *gin.Context) {

	var param model.BookMenu
	_ = c.ShouldBindJSON(&param)

	err, allAudio := service.GetAudioByClass(param)
	if err != nil {
		response.FailWithMessage("获取失败", c)
		return
	}
	response.OkWithData(allAudio, c)
	return
}
